<!DOCTYPE HTML>
<html>
<head>
<title>Boomerang Howto #8: Measure a user's DNS latency</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../boomerang-docs.css">
</head>
<body>
<span style="float:right;"><a href="../">All Docs</a> | <a href="index.html">Index</a></span>
<h1>Boomerang Howto #8: Measure a user's DNS latency</h1>
<p>
See <a href="../use-cases.html#uc-7">use case #7</a> for a description of this requirement.
</p>
<p>
<strong>Note:</strong> The DNS plugin hasn't been tested.  Your help in testing it is appreciated.
</p>
<p>
Measuring DNS requires some server-side set up.  The entire set up was
<a href="http://developer.yahoo.net/blog/archives/2009/11/guide_to_dns.html">documented in detail</a>
by Yahoo! engineer Carlos Bueno, so go read his post for everything you'll need to set
this up.  In brief, the points he covers are:
</p>
<ol>
<li>Set up a wildcard hostname, perferably one that does not share cookies with your main site.
Give it a low TTL, say, 60 seconds, so you don't pollute downstream caches.</li>
<li>Set up a webserver for the wildcard hostname that serves the images named <code>A.gif</code>
and <code>B.gif</code> (from the <a href="../../images/">images/</a> subdirectory) as fast as possible.
Make sure that KeepAlive, Nagle, and any caching headers are turned off.</li>
<li>Include <code>dns.js</code> along with <code>boomerang.js</code> (you can just concatenate the two
files)</li>
<li>Tell the DNS plugin where to get its images from</li>
</ol>

<p>
Steps 1 and 2 are complicated, and if you don't have full control over your DNS server (eg: you use
Dreamhost), then it may be impossible for you to do this.  If you can go forward, read on.
</p>

<p>
To configure the plugin, you only need to tell it where to get its images from.  Unlike the bandwidth
plugin though, this URL needs a wildcard:
</p>
<pre>
&lt;script src="boomerang.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="dns.js" type="text/javascript"&gt;&lt;/script&gt; &lt;!-- concatenate with boomerang.js for better performance --&gt;
&lt;script type="text/javascript"&gt;
BOOMR.init({
		user_ip: "&lt;user's ip address&gt;",
		beacon_url: "http://yoursite.com/path/to/beacon.php",
		<em>DNS: {                                         </em>
		<em>    base_url: "http://*.yoursite.com/images/"  </em>
		<em>}                                              </em>
	});
&lt;/script&gt;
</pre>

<p>
If you've set things up correctly, this should measure your DNS latency within a margin of error.
We could run the test multiple times to find out what this error is, but for now we'll just do
it once.
</p>

<p class="perma-link">
The latest code and docs is available on <a href="http://github.com/lognormal/boomerang/">github.com/lognormal/boomerang</a>
</p>

<p id="results">
</p>

<script src="../../boomerang.js" type="text/javascript"></script>
<script src="howtos.js" type="text/javascript"></script>
<script type="text/javascript">
BOOMR.init({
		user_ip: '10.0.0.1',
		BW: {
			base_url: '../../images/',
			cookie: 'HOWTO-BA'
		},
		RT: {
			cookie: 'HOWTO-RT'
		}
	});
</script>
</body>
</html>
